/// 1. 使用trait_bound有条件的实现方法
trait GetName {
    fn get_name(&self) -> &String;
}
trait GetAge {
    fn get_age(&self) -> u32;
}

struct PeopleMatchInformation<T, U> {
    teacher: T,
    student: U,
}

impl<T, U> PeopleMatchInformation<T, U>
where T: GetName+GetAge, U:GetName+GetAge{
    fn print_all_information(&self) {
        println!("master name = {}", self.teacher.get_name());
        println!("master name = {}", self.teacher.get_age());
        println!("student name = {}", self.student.get_name());
        println!("student name = {}", self.student.get_age());
    }
}
struct Teacher {
    name: String,
    age: u32,
}
impl GetName for Teacher {
    fn get_name(&self) -> &String {
        &self.name
    }
}
impl GetAge for Teacher {
    fn get_age(&self) -> u32 {
        self.age
    }
}

struct Student {
    name: String,
    age: u32,
}
impl GetName for crate::Student {
    fn get_name(&self) -> &String {
        &self.name
    }
}
impl GetAge for crate::Student {
    fn get_age(&self) -> u32 {
        self.age
    }
}
fn main() {
    let s = Student{name: "小米".to_string(), age: 15};
    let t = Teacher{name: "小张".to_string(), age: 30};
    let m = PeopleMatchInformation{teacher: t, student: s};
    m.print_all_information();
    println!("Hello, world!");
}
